home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
cattermi.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
32KB
|
1,047 lines
(*----------------------------------------------------------------------*
* *
* MAGICTOOLS Modula's All purpose GEM Interface Cadre Toolbox *
* ÿ ÿ ÿ ÿ ÿ *
*----------------------------------------------------------------------*
* Version 3.30 02.02.1992 (C)90/91/92 by Peter Hellinger Software *
*----------------------------------------------------------------------*
* Dieses Modul ist urheberrechtlich geschtzt. *
* *
* Die Verffentlichung des Quelltextes oder Teilen daraus, sowie die *
* Verbreitung des bersetzten, nicht gelinkten Codes in schriftlicher, *
* oder maschinenlesbarer Form, insbesondere in Zeitschriften, Mail- *
* boxen oder anderen Medien bedarf der ausdrcklichen schriftlichen *
* Einverstndnisserklrung des Autors. *
* *
* Die Verbreitung des Moduls als Teil eines gelinkten Programms ist *
* fr Lizenznehmer ausdrcklich erlaubt! Der Autor behlt sich das *
* Recht vor, diese Erlaubnis jederzeit und ohne Angaben von Grnden zu *
* widerrufen. *
*----------------------------------------------------------------------*)
IMPLEMENTATION MODULE CatTerminal;
(*----------------------------------------------------------------------*
* Int. Vers | Datum | Name | nderung *
*-----------+----------+------+----------------------------------------*
* 3.00 | 18.01.92 | Hp | *
* 3.01 | 31.01.92 | Hp | Bug in OpenTerminal gefixt, der dazu *
* | | | fhrte, da die falsche Fontgre ein- *
* | | | gestellt wurde. *
* 3.02 | 03.02.92 | Hp | Uralt-Bug in Emulator gefixt. *
* | | | Mhnie Znks to Steffen Engel @ PE *
*-----------+----------+------+----------------------------------------*)
(* IMPLEMENTATION FR >>> Megamax-Modula-2 <<< *)
(* *)
(*$R- Range-Checks *)
(*$S- Stack-Check *)
(* *)
(*----------------------------------------------*)
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
FROM MagicSys IMPORT Nil, Null, Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6,
Bit7, Bit8, Bit9, Bit10, Bit11, Bit12, Bit13, Bit14,
Bit15, LOC, Byte, ByteSet, sWORD, sINTEGER, sCARDINAL,
sBITSET, lINTEGER, lCARDINAL, lWORD, lBITSET,
CastToChar, CastToByte, CastToByteset, CastToInt,
CastToCard, CastToBitset, CastToWord, CastToLInt,
CastToLCard, CastToLBitset, CastToLWord, CastToAddr,
TosVersion, Accessory, Basepage, SysHeader, TosDate;
FROM SYSTEM IMPORT ADDRESS, ADR, TSIZE;
FROM MagicStrings IMPORT Assign, Append, Length;
FROM MagicConvert IMPORT CardToStr, IntToStr, LCardToStr, LIntToStr,
LRealToStr, RealToStr, FixRealToStr, FixLRealToStr;
FROM MagicVDI IMPORT VDIIntIn, VDIPtsIn, VDICall;
FROM mtAppl IMPORT VDIHandle, MaxWidth, MaxHeight, Bitplanes,
CharWidth, CharHeight, BoxWidth, BoxHeight,
OpenWorkstation, CloseWorkstation, MouseOn,
MouseOff, Screen;
FROM FontSelect IMPORT FontInfo, FontActive, FontSelect, FontSize,
tFontinfo;
FROM mtUtils IMPORT tRect;
IMPORT MagicBIOS, MagicDOS, MagicAES, MagicVDI;
(*--------------------------------------------------------------------------*
* Zustandsflags des Terminals *
*--------------------------------------------------------------------------*)
CONST cActive = 0; (* Terminal aktiv (Vordergrund) *)
cErase = 1; (* Zeichen vorlschen? *)
cCursor = 2; (* Cursor ein? *)
cBlink = 3; (* Cursor blinkend? *)
cWrap = 4; (* Word-Wrapping *)
cEscape = 5; (* Escape wurde ausgegeben *)
cEscYs = 6; (* Escape Y: Spaltenwert wird erwartet *)
cEscYz = 7; (* Escape Y: Zeilenwert wird erwartet *)
cEscb = 8; (* Escape b: Vordergrundfarbe wird erwartet *)
cEscc = 9; (* Escape c: Hintergrundfarbe wird erwartet *)
cBColor = 10; (* Hintergrundfarbe beim Schreiben *)
cRedraw = 11; (* Redrawfeature eingeschaltet *)
cFSM = 12; (* Gesetzt wenn der Font ein FSM-Font ist *)
cFlag13 = 13;
cFlag14 = 14;
cFlag15 = 15;
(*--------------------------------------------------------------------------*)
TYPE TERMINAL = POINTER TO TerminalTyp;
TerminalTyp = RECORD
x: sINTEGER; (* X-Koordinate *)
y: sINTEGER; (* Y-Koordinate *)
px: sINTEGER; (* X-Pixelpos des Cursor *)
py: sINTEGER; (* Y-Pixelpos des Cursors *)
mx: sINTEGER; (* Position rechter Rand *)
my: sINTEGER; (* Position linker Rand *)
lastCol: sINTEGER; (* Pixelpos der letzten Spalte *)
lastLn: sINTEGER; (* Pixelpos der letzten Zeile *)
zBreite: sINTEGER; (* Zeichenbreite *)
zHoehe: sINTEGER; (* Zeichenhhe *)
pmx: sINTEGER; (* Cursor-Breite *)
pmy: sINTEGER; (* Cursor-Hhe *)
sx: sINTEGER; (* *)
sy: sINTEGER; (* *)
ox: sINTEGER; (* *)
xoff: sINTEGER; (* Offset fr kursive Schrift *)
yoff: sINTEGER; (* fr tiefgestellte Schrift *)
w: sINTEGER; (* Breite in Pixel *)
h: sINTEGER; (* Hhe in Pixel *)
sp: sINTEGER; (* Anzahl der Spalten *)
zl: sINTEGER; (* Anzahl der Zeilen *)
wert1: sINTEGER; (* Zwischenspeicher *)
wert2: sINTEGER; (* Zwischenspeicher *)
vColor: sINTEGER; (* Vordergrundfarbe (Text) *)
hColor: sINTEGER; (* Hintergrundfarbe *)
tab: sINTEGER; (* Tabweite *)
size: sINTEGER; (* Fontgre *)
full: sINTEGER; (* Volle Fontgre *)
half: sINTEGER; (* Halbe Fontgre *)
font: sINTEGER; (* Fontnummer *)
effect: Attribut; (* Texteffekte *)
zustand: sBITSET; (* Zustand des Terminals *)
END; (* TerminalTyp *)
(*--------------------------------------------------------------------------*)
VAR d, q: MagicVDI.MFDB;
dPtr: ADDRESS;
qPtr: ADDRESS;
VAR control7: POINTER TO ADDRESS;
control9: POINTER TO ADDRESS;
VAR InversHandle: sINTEGER;
NormalHandle: sINTEGER;
VAR rect: tRect;
rect2: tRect;
VAR Status: sINTEGER;
VAR MaxLines: sINTEGER; (* max. Anzahl Zeilen des Bildschirms *)
MaxColumns: sINTEGER; (* max. Anzahl Spalten des Bildschirms *)
MinX: sINTEGER; (* Ursprung des Bildschirms *)
MinY: sINTEGER;
(*--------------------------------------------------------------------------*)
VAR conterm[0484H]: ByteSet;
PROCEDURE Glocke;
CONST glocke = 2;
VAR stack: ADDRESS;
BEGIN
stack:= 0; MagicDOS.Super (stack);
IF (glocke IN conterm) THEN MagicBIOS.Bconout (MagicBIOS.CON, CHR(7)); END;
MagicDOS.Super (stack);
END Glocke;
PROCEDURE Cursor;
(* Schaltet Cursor ein und aus, XOR-Modus *)
BEGIN
WITH Terminal^ DO
IF cCursor IN zustand THEN
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= pmx;
VDIPtsIn[3]:= pmy;
VDICall(114, 2, 0, 0, InversHandle);
END; (* IF cCursor *)
END; (* WITH *)
END Cursor;
PROCEDURE Scrollup;
(* Geht davon aus, da Maus und Cursor aus sind. Diese Routine wird nur
* intern aufgerufen, so da dieses Vorgehen keine Probleme bereitet
*)
BEGIN
WITH Terminal^ DO
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= y + zHoehe;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= my;
VDIPtsIn[4]:= x;
VDIPtsIn[5]:= y;
VDIPtsIn[6]:= mx;
VDIPtsIn[7]:= lastLn;
VDIIntIn[0]:= 3;
control7^:= qPtr;
control9^:= dPtr;
VDICall(109, 4, 1, 0, NormalHandle);
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= lastLn;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= my;
VDICall (114, 2, 0, 0, NormalHandle);
END;
END Scrollup;
PROCEDURE Emulator (ch: CHAR);
(* Handled alles, was mit Escape eingeleitet wurde *)
BEGIN
WITH Terminal^ DO
IF cEscYs IN zustand THEN
wert1:= ORD(ch) - 32;
EXCL (zustand, cEscYs); INCL (zustand, cEscYz); RETURN;
END;
IF cEscYz IN zustand THEN
wert2:= ORD(ch) - 32; IF wert2 < 0 THEN wert2:= 0; END;
GotoXY (wert2, wert1);
EXCL (zustand, cEscYz); EXCL (zustand, cEscape); RETURN;
END;
IF cEscb IN zustand THEN
ForegroundColor (ORD (ch));
EXCL (zustand, cEscb); EXCL (zustand, cEscape); RETURN;
END;
IF cEscc IN zustand THEN
BackgroundColor (ORD (ch));
EXCL (zustand, cEscc); EXCL (zustand, cEscape); RETURN;
END;
CASE ch OF
'A': IF py > y THEN DEC (py, zHoehe); DEC (pmy, zHoehe); END;|
'B': IF py < lastLn THEN INC (py, zHoehe); INC (pmy, zHoehe); END;|
'C': IF px < lastCol THEN INC(px, zBreite); INC(pmx, zBreite); END;|
'D': IF px > x THEN DEC (px, zBreite); DEC (pmx, zBreite); END;|
'E': ClearScreen;|
'H': GotoXY (0, 0);|
'I': IF py > y THEN DEC (py, zHoehe); DEC (pmy, zHoehe); END;
IF py = y THEN InsertLine; END;|
'J': ClearEndOfScreen;|
'K': ClearEndOfLine;|
'L': InsertLine;|
'M': DeleteLine;|
'Y': INCL (zustand, cEscYs); RETURN;|
'b': INCL (zustand, cEscb); RETURN;|
'c': INCL (zustand, cEscc); RETURN;|
'd': ClearStartOfScreen;|
'e': CursorOn;|
'f': CursorOff;|
'j': sx:= px; sy:= py;|
'k': px:= sx; py:= sy; pmx:= px + zBreite; pmy:= py + zHoehe;|
'l': ClearLine; px:= x; pmx:= px + zBreite;|
'o': ClearStartOfLine;|
'p': INCL (effect, invers);|
'q': EXCL (effect, invers);|
'v': INCL (zustand, cWrap);|
'w': EXCL (zustand, cWrap);|
200C..377C: SetAttribut (Attribut (ch));|
ELSE;
END; (* CASE *)
EXCL(zustand, cEscape);
END; (* WITH *)
END Emulator;
PROCEDURE ControlChar (ch: CHAR);
(* Bearbeitet alles was kleiner als Blank ist *)
VAR b: Attribut;
s: sINTEGER;
BEGIN
WITH Terminal^ DO
CASE ORD(ch) OF
0: |
7: Glocke;
|
8: (* Backspace *)
IF px > x THEN DEC (px, zBreite); DEC (pmx, zBreite); END;
VDIPtsIn[0]:= px; VDIPtsIn[1]:= py;
VDIPtsIn[2]:= pmx; VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
|
9: (* TAB *)
s:= x + (((((px - x) DIV zBreite) DIV tab) + 1) * tab) * zBreite;
DEC (s, zBreite);
IF (px + s) < lastCol THEN px:= s; ELSE px:= lastCol; END;
pmx:= px + zBreite;
|
10: (* Linefeed *)
INC(py, zHoehe);
IF py > lastLn THEN py:= lastLn; Scrollup; END;
pmy:= py + zHoehe;
|
12: (* Home *)
ClearScreen;
|
13: (* Carriage-Return *)
px:= x; pmx:= px + zBreite;
|
27: (* Escape *)
INCL(zustand, cEscape);
|
ELSE b:= effect; INCL (effect, invers);
WriteChar (CHR(ORD(ch)+ 64));
effect:= b;
END; (* CASE *)
END; (* WITH *)
END ControlChar;
PROCEDURE DoWrite (anzahl: sINTEGER);
BEGIN
WITH Terminal^ DO
(* Position *)
VDIPtsIn[0]:= ox;
VDIPtsIn[1]:= py;
(* Vorlschen? *)
IF {cErase, cBColor} <= zustand THEN
VDIPtsIn[2]:= px; VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
END;
INC (VDIPtsIn[0], xoff);
INC (VDIPtsIn[1], yoff);
VDICall (8, 1, anzahl, 0, TextHandle);
(* Invers? *)
IF invers IN effect THEN
VDIPtsIn[0]:= ox;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= px - sINTEGER(1);
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, InversHandle);
END;
END;
END DoWrite;
PROCEDURE WriteChar (ch: CHAR);
VAR i: sINTEGER;
BEGIN
MouseOff; Cursor;
WITH Terminal^ DO
IF cEscape IN zustand THEN
Emulator(ch); (* Esape-Code abhandeln *)
ELSIF ORD(ch) < 32 THEN
ControlChar(ch); (* Control-Code abhandeln *)
ELSE
(* Normales Zeichen *)
IF px > lastCol THEN
IF cWrap IN zustand THEN
px:= x; INC(py, zHoehe);
IF py > lastLn THEN py:= lastLn; Scrollup; END;
pmx:= px + zBreite; pmy:= py + zHoehe;
ELSE
px:= lastCol; pmx:= px + zBreite;
END;
END;
ox:= px; INC(px, zBreite);
VDIIntIn[0]:= ORD(ch); VDIIntIn[1]:= 0;
DoWrite (1);
pmx:= px + zBreite; pmy:= py + zHoehe;
Cursor;
END; (* IF *)
END; (* WITH *)
MouseOn;
END WriteChar;
PROCEDURE XconWrite (ch: CHAR);
(* Nur fr xconout-Routine *)
VAR i: sINTEGER;
BEGIN
Cursor;
WITH Terminal^ DO
IF cEscape IN zustand THEN
Emulator(ch); (* Esape-Code abhandeln *)
ELSIF ORD(ch) < 32 THEN
ControlChar(ch); (* Control-Code abhandeln *)
ELSE
(* Normales Zeichen *)
IF px > lastCol THEN
IF cWrap IN zustand THEN
px:= x; INC(py, zHoehe);
IF py > lastLn THEN py:= lastLn; Scrollup; END;
pmx:= px + zBreite; pmy:= py + zHoehe;
ELSE
px:= lastCol; pmx:= px + zBreite;
END;
END;
ox:= px; INC(px, zBreite);
VDIIntIn[0]:= ORD(ch); VDIIntIn[1]:= 0;
DoWrite (1);
pmx:= px + zBreite; pmy:= py + zHoehe;
Cursor;
END; (* IF *)
END; (* WITH *)
END XconWrite;
PROCEDURE WriteLine (REF string: ARRAY OF CHAR);
VAR c, d, l: sCARDINAL;
i, j: sINTEGER;
char: CHAR;
BEGIN
MouseOff; Cursor; c:= 0; l:= HIGH(string);
LOOP
IF (c > l) THEN EXIT; END; (* String zu Ende *)
CASE ORD (string[c]) OF
0: EXIT; (* String zu Ende *)
|
27: INC(c);
INCL(Terminal^.zustand, cEscape);
WHILE cEscape IN Terminal^.zustand DO
Emulator (string[c]);
INC(c); IF (c > l) THEN EXIT; END;
END;
|
1..26,
28..31: ControlChar(string[c]); INC(c);
|
ELSE (* Scanne String bis Zeichen < Blank und gebe ihn aus *)
WITH Terminal^ DO
d:= 0; ox:= px;
WHILE (px <= lastCol) & (string[c] > 37C) & (c <= l) DO
VDIIntIn[d]:= ORD(string[c]); INC(d); INC(c); INC(px, zBreite);
END;
VDIIntIn[d]:= 0;
IF ox < lastCol THEN DoWrite (d); END;
IF px >= lastCol THEN
IF cWrap IN zustand THEN
px:= x; INC(py, zHoehe);
IF py > lastLn THEN py:= lastLn; Scrollup; END;
pmx:= px + zBreite; pmy:= py + zHoehe;
ELSE
px:= lastCol; pmx:= px + zBreite;
END;
END;
END; (* WITH *)
END; (* CASE *)
END; (* LOOP *)
WITH Terminal^ DO pmx:= px + zBreite; END;
Cursor;
END WriteLine;
PROCEDURE WriteConst (REF string: ARRAY OF CHAR);
BEGIN
WriteLine(string);
END WriteConst;
PROCEDURE WriteLn;
BEGIN
MouseOff; Cursor;
WITH Terminal^ DO
px:= x;
INC(py, zHoehe);
IF py > lastLn THEN py:= lastLn; Scrollup; END;
pmx:= px + zBreite; pmy:= py + zHoehe;
END;
Cursor;
END WriteLn;
VAR string: ARRAY [0..255] OF CHAR;
PROCEDURE WriteCard (wert: sCARDINAL; len: sCARDINAL);
BEGIN
CardToStr (wert, len, string);
WriteLine (string);
END WriteCard;
PROCEDURE WriteInt (wert: sINTEGER; len: sCARDINAL);
BEGIN
IntToStr (wert, len, string);
WriteLine (string);
END WriteInt;
PROCEDURE WriteLongCard (wert: lCARDINAL; len: sCARDINAL);
BEGIN
LCardToStr (wert, len, string);
WriteLine (string);
END WriteLongCard;
PROCEDURE WriteLongInt (wert: lINTEGER; len: sCARDINAL);
BEGIN
LIntToStr (wert, len, string);
WriteLine (string);
END WriteLongInt;
PROCEDURE WriteReal (wert: REAL; len: sCARDINAL);
BEGIN
RealToStr (wert, len, string);
WriteLine (string);
END WriteReal;
PROCEDURE WriteLongReal (wert: LONGREAL; len: sCARDINAL);
BEGIN
LRealToStr (wert, len, string);
WriteLine (string);
END WriteLongReal;
PROCEDURE WriteFixReal (wert: REAL; len, fix: sCARDINAL);
BEGIN
FixRealToStr (wert, len, fix, string);
WriteLine (string);
END WriteFixReal;
PROCEDURE WriteFixLReal (wert: LONGREAL; len, fix: sCARDINAL);
BEGIN
FixLRealToStr (wert, len, fix, string);
WriteLine (string);
END WriteFixLReal;
PROCEDURE InsertLine;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; px:= x; pmx:= px + zBreite;
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= my - zHoehe;
VDIPtsIn[4]:= px;
VDIPtsIn[5]:= py + zHoehe;
VDIPtsIn[6]:= mx;
VDIPtsIn[7]:= my;
VDIIntIn[0]:= 3;
control7^:= qPtr;
control9^:= dPtr;
VDICall (109, 4, 1, 0, NormalHandle);
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
END;
END InsertLine;
PROCEDURE DeleteLine;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; px:= x; pmx:= px + zBreite;
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py + zHoehe;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= my;
VDIPtsIn[4]:= px;
VDIPtsIn[5]:= py;
VDIPtsIn[6]:= mx;
VDIPtsIn[7]:= lastLn;
VDIIntIn[0]:= 3;
control7^:= qPtr;
control9^:= dPtr;
VDICall (109, 4, 1, 0, NormalHandle);
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= lastLn;
VDIPtsIn[2]:= mx;
VDIPtsIn[3]:= my;
VDICall (114, 2, 0, 0, NormalHandle);
END;
END DeleteLine;
PROCEDURE WhereXY (VAR spalte, zeile: sCARDINAL);
BEGIN
WITH Terminal^ DO
spalte:= (px - x) DIV zBreite;
zeile:= (py - y) DIV zHoehe;
END;
END WhereXY;
PROCEDURE GotoXY (spalte, zeile: sCARDINAL);
(* Die Home-Position wurde auf 0, 0 festgelegt *)
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; (* Cursor ausschalten *)
px:= x + (CastToInt (spalte) * zBreite);
py:= y + (CastToInt (zeile) * zHoehe);
IF px < x THEN px:= x; END;
IF py < y THEN py:= y; END;
IF px > mx THEN px:= mx - zBreite; END;
IF py > lastLn THEN py:= lastLn; END;
pmx:= px + zBreite; pmy:= py + zHoehe;
Cursor;
END; (* WITH *)
END GotoXY;
PROCEDURE WhereCursor (VAR x, y: sINTEGER);
BEGIN
x:= Terminal^.px;
y:= Terminal^.py;
END WhereCursor;
PROCEDURE SetCursor (xx, yy: sINTEGER);
VAR bb, hh: sINTEGER;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; (* Cursor ausschalten *)
px:= xx; py:= yy;
IF px < x THEN px:= x; END;
IF py < y THEN py:= y; END;
IF px > mx THEN px:= mx - zBreite; END;
IF py > lastLn THEN py:= lastLn; END;
pmx:= px + 2;
pmy:= py + zHoehe - 1;
Cursor;
END; (* WITH *)
END SetCursor;
PROCEDURE CursorOn;
BEGIN
IF NOT (cCursor IN Terminal^.zustand) THEN
MouseOff; INCL(Terminal^.zustand, cCursor); Cursor;
END;
END CursorOn;
PROCEDURE CursorOff;
BEGIN
IF cCursor IN Terminal^.zustand THEN
MouseOff; Cursor; EXCL(Terminal^.zustand, cCursor);
END;
END CursorOff;
PROCEDURE CursorStop;
(* Wird ggw. nicht untersttzt *)
END CursorStop;
PROCEDURE CursorBlink;
(* Wird ggw. nicht untersttzt *)
END CursorBlink;
PROCEDURE WrapOff;
BEGIN
EXCL(Terminal^.zustand, cWrap);
END WrapOff;
PROCEDURE WrapOn;
BEGIN
INCL(Terminal^.zustand, cWrap);
END WrapOn;
PROCEDURE ClearLine;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; px:= x; pmx:= px + zBreite;
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= x + w -1;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END;
END ClearLine;
PROCEDURE ClearStartOfLine;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor;
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= px;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END;
END ClearStartOfLine;
PROCEDURE ClearEndOfLine;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor;
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= x + w - 1;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END;
END ClearEndOfLine;
PROCEDURE ClearScreen;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor; GotoXY (0, 0);
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= x + w - 1;
VDIPtsIn[3]:= y + h - 1;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END; (* WITH *)
END ClearScreen;
PROCEDURE ClearStartOfScreen;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor;
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= x;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= y;
VDIPtsIn[2]:= x + w - 1;
VDIPtsIn[3]:= py;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END; (* WITH *)
END ClearStartOfScreen;
PROCEDURE ClearEndOfScreen;
BEGIN
WITH Terminal^ DO
MouseOff; Cursor;
VDIPtsIn[0]:= px;
VDIPtsIn[1]:= py;
VDIPtsIn[2]:= x + w - 1;
VDIPtsIn[3]:= pmy;
VDICall (114, 2, 0, 0, NormalHandle);
VDIPtsIn[0]:= x;
VDIPtsIn[1]:= py + zHoehe;
VDIPtsIn[2]:= x + w - 1;
VDIPtsIn[3]:= y + h - 1;
VDICall (114, 2, 0, 0, NormalHandle);
Cursor;
END; (* WITH *)
END ClearEndOfScreen;
PROCEDURE ForegroundColor (color: sINTEGER);
VAR old: sINTEGER;
BEGIN
Terminal^.vColor:= color;
old:= MagicVDI.SetTextcolor (TextHandle, color);
old:= MagicVDI.SetFillcolor (InversHandle, color);
END ForegroundColor;
PROCEDURE BackgroundColor (color: sINTEGER);
VAR old, wm: sINTEGER;
BEGIN
Terminal^.hColor:= color;
old:= MagicVDI.SetFillcolor (NormalHandle, color);
IF color > 0 THEN
INCL (Terminal^.zustand, cBColor);
wm:= MagicVDI.SetWritemode (TextHandle, MagicVDI.XOR);
ELSE
EXCL (Terminal^.zustand, cBColor);
wm:= MagicVDI.SetWritemode (TextHandle, MagicVDI.REPLACE);
END;
END BackgroundColor;
PROCEDURE InversOn;
BEGIN
INCL (Terminal^.effect, invers);
END InversOn;
PROCEDURE InversOff;
BEGIN
EXCL (Terminal^.effect, invers);
END InversOff;
PROCEDURE SetAttribut (attrib: Attribut);
VAR i: sINTEGER;
bs: sBITSET;
BEGIN
MouseOff;
WITH Terminal^ DO
IF Attribut{subscript, superscript, italic} <= attrib THEN
(* Das zu schreibende Zeichen mu am Bildschirm vorgelscht werden *)
INCL(zustand, cErase);
END;
(* Bei kursiver Schrift mu das Zeichen um einen Offset nach rechts
* verschoben werden, da durch die Umsetzung des Alignments das Zeichen
* nach links gezeichnet wird (kompliziert, ich geb's zu...)
*)
IF italic IN attrib THEN
xoff:= zBreite DIV 2;
rect.x:= x; rect.y:= y; rect.w:= x + w - 2; rect.h:= y + h - 2;
MagicVDI.SetClipping(TextHandle, rect, TRUE);
ELSIF italic IN effect THEN
xoff:= 0;
MagicVDI.SetClipping(TextHandle, rect, FALSE);
ELSE
xoff:= 0;
END;
(* Beim Tiefstellen von Zeichen mu noch ein Offset addiert werden,
* da unsere Cursorposition immer die oberste Rasterzeile des Zeichens
* beschreibt.
*)
IF Attribut{subscript, superscript} <= attrib THEN
yoff:= zHoehe DIV 4;
size:= MagicVDI.SetCharpoints (TextHandle, half, i, i, i, i);
ELSIF subscript IN attrib THEN
yoff:= zHoehe DIV 2;
size:= MagicVDI.SetCharpoints (TextHandle, half, i, i, i, i);
ELSIF superscript IN attrib THEN
yoff:= 0;
size:= MagicVDI.SetCharpoints (TextHandle, half, i, i, i, i);
ELSE (* Normale Zeichenhhe *)
yoff:= 0;
size:= MagicVDI.SetCharpoints (TextHandle, full, i, i, i, i);
END;
(* Leider werden nicht alle verwendeten Attribute vom VDI untersttzt.
* So werden Hoch-, Tiefstellen und Invers in MagicTerm emuliert.
* Diese Bits mssen wir ausblenden, sonst gibts Verwirrung
*)
bs:= {};
IF fat IN attrib THEN INCL (bs, MagicVDI.Fat); END;
IF light IN attrib THEN INCL (bs, MagicVDI.Light); END;
IF italic IN attrib THEN INCL (bs, MagicVDI.Italic); END;
IF underline IN attrib THEN INCL (bs, MagicVDI.Underline); END;
VDIIntIn[0]:= CastToInt (bs);
VDICall (106, 0, 1, 0, TextHandle);
effect:= attrib;
END; (* WITH *)
END SetAttribut;
PROCEDURE SetTabspace (tab: sINTEGER);
BEGIN
Terminal^.tab:= tab;
END SetTabspace;
PROCEDURE SetParameter;
BEGIN
WITH Terminal^ DO
Lines:= zl; Columns:= sp;
Xpos:= x; Ypos:= y; Width:= w; Height:= h;
CurrWidth:= zBreite; CurrHeight:= zHoehe;
END;
END SetParameter;
(*--------------------------------------------------------------------------*
* GDOS-Fonthandling *
*--------------------------------------------------------------------------*)
PROCEDURE UpdateTerminal;
VAR info: tFontinfo;
BEGIN
WITH Terminal^ DO
font:= FontActive (TextHandle);
FontInfo (TextHandle, font, info);
size:= info.point; full:= info.point;
IF info.fsm THEN INCL (Terminal^.zustand, cFSM); half:= full DIV 2;
ELSE EXCL (Terminal^.zustand, cFSM); half:= full - 1;
END;
zBreite:= info.boxw;
zHoehe:= info.boxh;
sp:= w DIV zBreite;
zl:= h DIV zHoehe;
mx:= x + (sp * zBreite) - 1;
my:= y + (zl * zHoehe) - 1;
lastCol:= mx - zBreite + 1;
lastLn:= my - zHoehe + 1;
px:= x;
py:= y;
pmx:= x + zBreite;
pmy:= y + zHoehe;
END;
SetParameter;
END UpdateTerminal;
(*--------------------------------------------------------------------------*
* Support fr mehrere Terminals *
*--------------------------------------------------------------------------*)
VAR a, b, c: sINTEGER;
count: sINTEGER;
PROCEDURE OpenTerminal (rect: ARRAY OF LOC): TERMINAL;
VAR term: TERMINAL;
r: POINTER TO tRect;
i, j, s: sINTEGER;
info: tFontinfo;
BEGIN
ALLOCATE (term, TSIZE(TerminalTyp));
IF term # NIL THEN
WITH term^ DO
r:= ADR (rect); x:= r^.x; y:= r^.y; w:= r^.w; h:= r^.h;
IF (w + x) > MaxWidth THEN w:= MaxWidth - x; END;
IF (h + y) > MaxHeight THEN h:= MaxHeight - y; END;
font:= FontActive (TextHandle);
FontInfo (TextHandle, font, info);
size:= info.point; full:= info.point;
IF info.fsm THEN INCL (term^.zustand, cFSM); half:= full DIV 2;
ELSE EXCL (term^.zustand, cFSM); half:= full - 1;
END;
zBreite:= info.boxw;
zHoehe:= info.boxh;
sp:= w DIV zBreite;
zl:= h DIV zHoehe;
mx:= x + (sp * zBreite) - 1;
my:= y + (zl * zHoehe) - 1;
lastCol:= mx - zBreite + 1;
lastLn:= my - zHoehe + 1;
px:= x;
py:= y;
pmx:= x + zBreite;
pmy:= y + zHoehe;
vColor:= 1;
hColor:= 0;
xoff:= 0;
yoff:= 0;
tab:= 8;
effect:= Attribut{}; zustand:= {};
END; (* WITH *)
END;
RETURN term;
END OpenTerminal;
PROCEDURE CloseTerminal (VAR term: TERMINAL);
BEGIN
DEALLOCATE (term, 0);
END CloseTerminal;
PROCEDURE ChangeTerminal (term: TERMINAL): TERMINAL;
VAR old: TERMINAL;
BEGIN
old:= Terminal;
EXCL (old^.zustand, cActive); INCL (term^.zustand, cActive);
Terminal:= term;
WITH Terminal^ DO
IF old^.font # font THEN FontSelect (TextHandle, font); END;
UpdateTerminal;
ForegroundColor (vColor);
BackgroundColor (hColor);
SetAttribut (effect);
END;
SetParameter;
RETURN old;
END ChangeTerminal;
PROCEDURE GetMaximum (VAR rect: ARRAY OF LOC);
VAR r: POINTER TO tRect;
BEGIN
r:= ADR (rect);
r^.x:= MinX; r^.y:= MinY; r^.w:= MaxWidth; r^.h:= MaxHeight;
END GetMaximum;
PROCEDURE GetTerminal (VAR rect: ARRAY OF LOC);
VAR r: POINTER TO tRect;
BEGIN
r:= ADR (rect);
r^.x:= Terminal^.x;
r^.y:= Terminal^.y;
r^.w:= Terminal^.w;
r^.h:= Terminal^.h;
END GetTerminal;
PROCEDURE SetTerminal (rect: ARRAY OF LOC);
VAR r: POINTER TO tRect;
i, chw, chh, boxw, boxh: sINTEGER;
BEGIN
WITH Terminal^ DO
r:= ADR (rect); x:= r^.x; y:= r^.y; w:= r^.w; h:= r^.h;
IF (w + x) > MaxWidth THEN w:= MaxWidth - x; END;
IF (h + y) > MaxHeight THEN h:= MaxHeight - y; END;
UpdateTerminal;
END;
END SetTerminal;
PROCEDURE ClipRect (doit: BOOLEAN; rct: ARRAY OF LOC);
VAR r: POINTER TO tRect;
BEGIN
r:= ADR (rct);
IF doit THEN
rect.x:= r^.x;
rect.y:= r^.y;
rect.w:= r^.x + r^.w - 1;
rect.h:= r^.y + r^.h - 1;
MagicVDI.SetClipping(TextHandle, rect, TRUE);
MagicVDI.SetClipping(NormalHandle, rect, TRUE);
MagicVDI.SetClipping(InversHandle, rect, TRUE);
ELSIF (italic IN Terminal^.effect) THEN
rect.x:= Terminal^.x;
rect.y:= Terminal^.y;
rect.w:= Terminal^.mx;
rect.h:= Terminal^.my;
MagicVDI.SetClipping(TextHandle, rect, TRUE);
MagicVDI.SetClipping(NormalHandle, rect, FALSE);
MagicVDI.SetClipping(InversHandle, rect, FALSE);
ELSE
MagicVDI.SetClipping(TextHandle, rect, FALSE);
MagicVDI.SetClipping(NormalHandle, rect, FALSE);
MagicVDI.SetClipping(InversHandle, rect, FALSE);
END;
END ClipRect;
PROCEDURE RedrawTerminal (term: TERMINAL; rect: ARRAY OF LOC);
BEGIN
END RedrawTerminal;
(*-------------------------------------------------------------------------*)
VAR j, i, i1, i2, i3, i4: sINTEGER;
x: TERMINAL;
r: tRect;
BEGIN
count:= 0; dPtr:= ADR(d); qPtr:= ADR(q);
control7:= ADR (MagicVDI.VDIControl[7]);
control9:= ADR (MagicVDI.VDIControl[9]);
InversHandle:= OpenWorkstation (Screen, 0, 0, TRUE);
i:= MagicVDI.SetWritemode (InversHandle, MagicVDI.XOR);
i:= MagicVDI.SetFillinterior (InversHandle, MagicVDI.Full);
i:= MagicVDI.SetFillcolor (InversHandle, 1);
NormalHandle:= OpenWorkstation (Screen, 0, 0, TRUE);
i:= MagicVDI.SetWritemode (NormalHandle, MagicVDI.REPLACE);
i:= MagicVDI.SetFillinterior (NormalHandle, MagicVDI.Full);
i:= MagicVDI.SetFillcolor (NormalHandle, 0);
TextHandle:= OpenWorkstation (Screen, 0, 0, TRUE);
i:= MagicVDI.SetTextface (TextHandle, 1);
i:= MagicVDI.SetWritemode (TextHandle, MagicVDI.REPLACE);
i:= MagicVDI.SetTextcolor (TextHandle, 1);
MagicVDI.SetTextalignment (TextHandle, 0, 5, i, i);
r.x:= 0; r.y:= 0; r.w:= MaxWidth; r.h:= MaxHeight;
Terminal:= OpenTerminal (r);
IF Terminal = NIL THEN HALT; END;
Terminal^.zustand:= {cActive};
SetParameter;
END CatTerminal.